package blocksim.util;

import java.util.Arrays;

/**
 * This wrapper is needed to represent a byte array as an object. It is useful
 * when adding byte arrays in List, Maps, etc.
 * 
 * @author marcus
 * 
 */
public final class ByteArrayWrapper {
  private final byte[] data;

  public ByteArrayWrapper(byte[] data) {
    if (data == null) {
      throw new NullPointerException();
    }
    this.data = data;
  }

  @Override
  public boolean equals(Object other) {
    if (!(other instanceof ByteArrayWrapper)) {
      return false;
    }
    return Arrays.equals(data, ((ByteArrayWrapper) other).data);
  }

  @Override
  public int hashCode() {
    return Arrays.hashCode(data);
  }
}